using IcsSEMCtrl.Boot;
using IcsSEMCtrl.Event;
using IcsSEMCtrl.Global;
using IcsSEMCtrl.Service.Alarm;
using IcsSEMCtrl.Service.Device;
using IcsSEMCtrl.Service.EventBroker;
using IcsSEMCtrl.Service.Logger;
using IcsSEMCtrl.Service.Material;
using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Runtime.Remoting;
namespace IcsSEMCtrl.Util.Client
{
	public class Naming
	{
		public static readonly string CarrierManager_ID = "CarrierManager";
		public static readonly string UserManager_ID = "UserManager";
		public static readonly string LogManager_ID = "LogManager";
		public static readonly string EventBrokerManager_ID = "EventBrokerManager";
		public static readonly string StatisticsManager_ID = "StatisticsManager";
		public static readonly string DeviceManager_ID = "DeviceManager";
		public static readonly string AlarmManager_ID = "AlarmManager";
		public static void Init()
		{
		}
		public static void Init(string remoteConfigFileName)
		{
			RemotingConfiguration.Configure(remoteConfigFileName, false);
			NameValueCollection appSettings = ConfigurationManager.AppSettings;
            //Naming.launcher = (Launcher)Activator.GetObject(typeof(Launcher), string.Concat(new string[]
            //{
            //    "tcp://",
            //    appSettings[ECPProperties.NamingHost].ToString(),
            //    ":",
            //    appSettings[ECPProperties.NamingPort].ToString(),
            //    "/Launcher"
            //}));
		}
		public static void Init(Launcher localLauncher)
		{
            //Naming.launcher = localLauncher;
		}
		public static CarrierManager GetCarrierManager()
		{
			return (CarrierManager)Launcher.GetLauncher().GetManager(Naming.CarrierManager_ID);
		}
		public static EventBrokerManager GetEventBrokerManager()
		{
			return (EventBrokerManager)Launcher.GetLauncher().GetManager(Naming.EventBrokerManager_ID);
		}
		public static DeviceManager GetDeviceManager()
		{
			return (DeviceManager)Launcher.GetLauncher().GetManager(Naming.DeviceManager_ID);
		}
		public static AlarmManager GetAlarmManager()
		{
			return (AlarmManager)Launcher.GetLauncher().GetManager(Naming.AlarmManager_ID);
		}
		public static void PublishEvent(string subject, ECPEvent ecpEvent)
		{
			Naming.GetEventBrokerManager().Publish(subject, ecpEvent);
		}
	}
}
